package main

import (
	"context"
	_ "inventory-system/routers"
	"inventory-system/services"

	"github.com/beego/beego/v2/core/logs"
	beego "github.com/beego/beego/v2/server/web"
)

func main() {
	// 初始化Elasticsearch
	err := services.InitElasticsearch()
	if err != nil {
		logs.Error("Failed to initialize Elasticsearch:", err)
		return
	}

	// 创建索引
	ctx := context.Background()
	err = services.CreateProductIndex(ctx)
	if err != nil {
		logs.Error("Failed to create index:", err)
		return
	}

	logs.Info("Inventory system started successfully")
	beego.Run()
}
